<template>
  <div class='com-news'>
    <div v-for="(item, index) in listData" :key="index">
      <ComHead :data="item.headData" :index="index" @getList="getList(index)"/>
      <div class="com-news-list">
        <Unit v-if="item.list" v-for="(opt, optIndex) in item.list" :info="opt" :key="optIndex" />
      </div>
    </div>
  </div>
</template>
<script>
import ComHead from '../hotSales/head.vue'
import Unit from './unit.vue'
export default {
  components: {ComHead,Unit},
  name: "",
  data() {
    return {
      listData:[
        {
          headData:[
            {label:"风类资讯实时",class:"title color-blue ft20"},
            {label:"查看更多",class:"ft14 ml-auto mr15 hover",click:this.getList,},
          ],
          list:[
          ]
        },{
          headData:[
            {label:"水类资讯",class:"title color-yellow ft20"},
            {label:"查看更多",class:"ft14 ml-auto mr15 hover",click:this.getList,},
          ],
          list:[]
        },{
          headData:[
            {label:"电类资讯",class:"title color-red ft20"},
            {label:"查看更多",class:"ft14 ml-auto mr15 hover",click:this.getList,},
          ],
          list:[]
        },{
          headData:[
            {label:"消防类资讯",class:"title color-green ft20"},
            {label:"查看更多",class:"ft14 ml-auto mr15 hover",click:this.getList,},
          ],
          list:[]
        },
        
      ]
    };
  },
  methods: {
      init(i){
            _g.apiPost('protalHome/informationList.do',{currPageNo:1,pageSize:3,type:i}).then(res=>{
                if(res.status===0){
                    this.listData[i].list = res.data.list
                }else{
                    _g.toMessage(res)
                }
            })
      },
      getList(index){
          this.$router.push({path:"/news/lists",query:{id:index}})
      }

  },
  created(){
      this.listData.forEach((el,index)=>{
          this.init(index)
      })


  }

};
</script>
<style lang="scss" scoped>
.com-news {
  display: flex;
  justify-content: space-between;

  >div{
    width: calc(25% - 15px);
    background-color: #fff;
    
  }
  .com-news-list{
    box-sizing: border-box;
    padding: 5px 0;
  }
}
</style>